import time
import ntptime
import network
from ST7735 import TFT
from machine import SPI,Pin

#hardware SPI, HSPI
spi=SPI(1,baudrate=40000000, polarity=0, phase=0, sck=Pin(2), mosi=Pin(3))
tft=TFT(spi,'/combined.bin',6,10,7)# dc, rst, cs   #6,10,7 aDC, aReset, aCS
tft.rgb(False)
tft.init_7735(tft.REDTAB80x160)


while True:
    mytime = time.localtime()

    # 获取小时、分钟和秒，并添加零前缀
    hours = (mytime[3] + 8) % 24
    minutes = mytime[4]
    seconds = mytime[5]

    hours_str = f'{hours:02d}'
    minutes_str = f'{minutes:02d}'
    seconds_str = f'{seconds:02d}'


    Ltime = f'{hours_str}:{minutes_str}:{seconds_str}'


    time.sleep(1)
    
    tft.fill(TFT.WHITE)
    chars = str(Ltime)
    tft.text((0,0),chars,TFT.BLACK,(2,2))
    time.sleep(2)